package com.atguigu.tingshu.user.client;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.client.impl.UserDegradeFeignClient;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户模块远程调用API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(value = "service-user", path = "api/user", fallback = UserDegradeFeignClient.class)
public interface UserFeignClient {

    /**
	 * 根据用户ID查询用户基本信息
	 * @param userId
	 * @return
	 */
	@GetMapping("/userInfo/getUserInfoVo/{userId}")
	public Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId);


	/**
	 * 判断指定专辑下声音ID购买状态
	 * @param userId 用户ID
	 * @param albumId 专辑ID
	 * @param needCheckPayStatusTrackIds 专辑某页需要检查购买状态声音ID列表
	 * @return {10001:1,10002:0,待检测声音ID：购买状态}
	 */
	@PostMapping("/userInfo/userIsPaidTrack/{userId}/{albumId}")
	public Result<Map<Long, Integer>> userIsPaidTrack(
			@PathVariable Long userId,
			@PathVariable Long albumId,
			@RequestBody List<Long> needCheckPayStatusTrackIds
	);

	/**
	 * 根据套餐ID查询套餐详情
	 * @param id
	 * @return
	 */
	@GetMapping("/vipServiceConfig/getVipServiceConfig/{id}")
	public Result<VipServiceConfig> getVipServiceConfig(@PathVariable Long id);


	/**
	 * 判断当前用户是否购买过指定专辑
	 *
	 * @param albumId
	 * @return
	 */
	@GetMapping("/userInfo/isPaidAlbum/{albumId}")
	public Result<Boolean> isPaidAlbum(@PathVariable Long albumId);

	/**
	 * 获取当前用户指定专辑下已购声音ID列表
	 *
	 * @param albumId 专辑ID
	 * @return
	 */
	@GetMapping("/userInfo/findUserPaidTrackList/{albumId}")
	public Result<List<Long>> getUserPaidTrackIdList(@PathVariable Long albumId);

	/**
	 * 用户付款成功后（余额、微信），进行虚拟物品（会员、专辑、声音）发货
	 * @param userPaidRecordVo
	 * @return
	 */
	@PostMapping("/userInfo/savePaidRecord")
	public Result savePaidRecord(@RequestBody UserPaidRecordVo userPaidRecordVo);


	/**
	 * 更新VIP状态：处理过期会员
	 * @return
	 */
	@GetMapping("/updateVipExpireStatus")
	public Result updateVipExpireStatus();
}
